import { APollingTask, CacheData } from "../../PollingStation";

export class CacheDataSource<T extends ICacheSourceTask=ICacheSourceTask> extends CacheData<T>
{

}

export class CacheSourceTask<T = CacheDataSource<ICacheSourceTask>> extends APollingTask<T>
{
    // roomName!:string;

    Update(...arg:any[]): void
    {
        // this.roomName = arg[0];
        const room = Game.rooms[this.code];
        if(room)
        {
            const depos = room.find(FIND_SOURCES);
            const cachedata:ICacheSourceTask[]  = _.map(depos,item=>{
                const ret:ICacheSourceTask= {
                    id:item.id as string,
                    pos:item.pos,
                } as ICacheSourceTask;
                return ret;
            });
            this.value = new CacheDataSource<ICacheSourceTask>(cachedata) as unknown as  T;
            this.lastupdate =-1;
        }
    }

}
